package com.subfg.common.util.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.subfg.common.constant.PayMethodEnum;
import com.subfg.common.entity.excpetion.BusinessExceptionModel;

import java.io.IOException;

public class PayChnnelSerializer extends JsonSerializer<String> {
    @Override
    public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String paychnnel = "";
        try {
            PayMethodEnum payMethodEnum = PayMethodEnum.getSysPatMethod(s);
            paychnnel = payMethodEnum.getPayType();
        } catch (BusinessExceptionModel businessExceptionModel) {
            paychnnel = "unknown";
        }
        jsonGenerator.writeString(paychnnel);
    }
}
